import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

enum Api {
  list = '/auth-service/loginLog/page',
  delete = '/auth-service/loginLog/delete',
  clean = '/auth-service/loginLog/clean',
  deleteBatch = '/auth-service/loginLog/deleteBatch',
}


export const getLogList = (params) => defHttp.get({ url: Api.list, params });

export const cleanLog = (handleSuccess) => {
  return defHttp.delete({ url: Api.clean}, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};


export const deleteLog = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};


export const batchDeleteLog = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};

